#include "Menu.h"

Menu::Menu()
{
	// default menu has no buttons. Custom menus should inherit from this
	// class and implement button initialization in their own constructor
	mHasFocus = false;
}

Menu::~Menu()
{
	while (mButtons.size() > 0)
	{
		std::vector<MenuButton*>::iterator i = mButtons.begin();
		delete *i;
		mButtons.erase(i);
	}
}

void Menu::Update(POINT mousepos, bool clicked)
{
	mHasFocus = false;// assume false during this iteration until a button returns true
	for(std::vector<MenuButton*>::iterator i = mButtons.begin(); i != mButtons.end(); ++i)
	{
		if ((*i)->Update(mousepos, clicked))
		{
			mHasFocus = true;
		}
	}
}

void Menu::OnResetDevice(float bbwidth, float bbheight)
{
	for(std::vector<MenuButton*>::iterator i = mButtons.begin(); i != mButtons.end(); ++i)
	{
		(*i)->OnResetDevice(bbwidth, bbheight);
	}
}

// renders all menu buttons
void Menu::Render(void)
{
	for(std::vector<MenuButton*>::iterator i = mButtons.begin(); i != mButtons.end(); ++i)
	{
		(*i)->Render();
	}
}